﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div id="approvalPage" class="main-content">

    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">保养记录签核Maintenance record signing</h3>
            <div class="right">
                <button type="button" class="btn-toggle-collapse"><i class="fa fa-angle-up"></i></button>
            </div>
        </div>
        <div class="panel-body">
            <form id="recordForm" class="form-horizontal">
                <div id="recordDate" class="form-group">
                    <label for="recordDate" class="col-sm-2 control-label">保养日期Maintenance date</label>
                    <div class="col-sm-7">
                        <div class="input-group input-group-sm">
                            <input id="recordDatePicker" type="text" class="form-control" v-model="record.BaseInfo.RecordDate" disabled />
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div id="equipmentCode" class="form-group">
                    <label for="equipmentCode" class="col-sm-2 control-label">设备编号Equipment number</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" placeholder="请填保养设备的公司编号Please fill in the company number of the maintenance equipment" v-model="record.Equipment.BaseInfo.Code" disabled />
                    </div>
                </div>
                <div id="equipmentInfo" class="form-group">
                    <div class="col-sm-offset-2 col-sm-7">
                        <table class="table table-bordered">
                            <tbody>
                                <tr class="warning">
                                    <td>设备名称Equipment name</td>
                                    <td>{{record.Equipment.BaseInfo.Name}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>设备型号Equipment model</td>
                                    <td>{{record.Equipment.BaseInfo.Model}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>使用楼层use storey</td>
                                    <td>{{record.Equipment.BaseInfo.Floor}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>设备状态Equipment status</td>
                                    <td>
                                        <span v-for="(value, key, idx) in statusDictionary">
                                            <span v-if="value == record.Equipment.BaseInfo.Status">{{key}}</span>
                                        </span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div id="approverName" class="form-group">
                    <label for="approverName" class="col-sm-2 control-label">管理员（签核）Administrator(sign off)</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" placeholder="请填签核人姓名Please fill in the name of the approver" v-model="record.ApproverInfo.Name" disabled />
                    </div>
                </div>
                <div id="approverInfo" class="form-group">
                    <div class="col-sm-offset-2 col-sm-7">
                        <table class="table table-bordered">
                            <tbody>
                                <tr class="warning">
                                    <td>邮箱mailbox</td>
                                    <td>{{record.ApproverInfo.Email}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>电话Telephone</td>
                                    <td>{{record.ApproverInfo.Mobile}}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div id="checkerName" class="form-group">
                    <label for="checkerName" class="col-sm-2 control-label">保养人Maintainer</label>
                    <div class="col-sm-7">
                        <input type="text" class="form-control" placeholder="请填保养人姓名Please fill in the name of the maintainer" v-model="record.CheckerInfo.Name" disabled />
                    </div>
                </div>
                <div id="checkerInfo" class="form-group">
                    <div class="col-sm-offset-2 col-sm-7">
                        <table class="table table-bordered">
                            <tbody>
                                <tr class="warning">
                                    <td>邮箱mailbox</td>
                                    <td>{{record.CheckerInfo.Email}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>电话Telephone</td>
                                    <td>{{record.CheckerInfo.Mobile}}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div id="templateFormID" class="form-group">
                    <label for="templateFormID" class="col-sm-2 control-label">保养单模板Maintenance order template</label>
                    <div class="col-sm-7">
                        <select class="form-control" v-model="record.TemplateForm.BaseInfo.ID" disabled>
                            <option v-for="(form, index) in templateFormList" v-bind:value="form.ID">{{form.Name}}</option>
                        </select>
                    </div>
                </div>
                <div id="maintItems" class="form-group">
                    <label for="maintItems" class="col-sm-2 control-label">保养项目maintenance program</label>
                    <div class="col-sm-7">
                        <ul class="list-group">
                            <li :id="'itemRecord' + index" class="list-group-item" v-for="(item, index) in record.TemplateForm.Items">
                                <div class="row">
                                    <div class="col-xs-8">
                                        <h5>{{item.Name}}</h5>
                                    </div>
                                    <div class="col-xs-4 text-right">
                                        <button class="btn btn-danger btn-xs" disabled>不通过Fail</button>
                                        <button class="btn btn-success btn-xs" disabled>通过adopt</button>
                                    </div>
                                    <div class="col-xs-12">
                                        <input :id="'itemRemark' + index" class="form-control input-sm" type="text" disabled/>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
                <div v-for="(approval, index) in record.Approvals" class="form-group">
                    <label class="col-sm-2 control-label">{{approval.SectionDetail.SectionName}}</label>
                    <div v-if="approval.SectionDetail.SectionStatus > 0" class="col-sm-7">
                        <table class="table table-bordered">
                            <tbody>
                                <tr>
                                    <td v-if="approval.SectionDetail.SectionStatus == 1" class="info">
                                        签核员Signer{{approval.SectionApprover.Name}} - {{approval.SectionApprover.NameChs}} - [{{approval.SectionApprover.ID}}]
                                        已经于Already on{{approval.SectionDetail.UpdateDate}}签核通过Approved by signature。理由reason[{{approval.SectionDetail.Remark}}]
                                    </td>
                                    <td v-if="approval.SectionDetail.SectionStatus == 2" class="danger">
                                        签核员Signer{{approval.SectionApprover.Name}} - {{approval.SectionApprover.NameChs}} - [{{approval.SectionApprover.ID}}]
                                        已经于Already on{{approval.SectionDetail.UpdateDate}}签核拒绝Sign off rejection。理由reason[{{approval.SectionDetail.Remark}}]
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div v-else-if="!isNotEmptyObject(approval.SectionApprover)" class="col-sm-7">
                        <table class="table table-bordered">
                            <tbody>
                                <tr class="danger">
                                    <td>请注意：当前用户不属于该签核节点成员或上一个签核节点未通过，请检查Please note: the current user is not a member of this check-out node or the previous check-out node failed. Please check。</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div v-else class="col-sm-7">
                        <table class="table table-bordered">
                            <tbody>
                                <tr class="warning">
                                    <td>当前签核人Current approver</td>
                                    <td>{{approval.SectionApprover.Name}} - {{approval.SectionApprover.NameChs}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>邮箱mailbox</td>
                                    <td>{{approval.SectionApprover.Email}}</td>
                                </tr>
                                <tr class="warning">
                                    <td>电话Telephone</td>
                                    <td>{{approval.SectionApprover.Mobile}}</td>
                                </tr>
                            </tbody>
                        </table>
                        <textarea class="form-control" placeholder="(可选)请填写签核备注(optional) please fill in the signing remarks" v-model="approval.SectionDetail.Remark" v-bind:disabled="!isNotEmptyObject(approval.SectionApprover)"></textarea>
                        <br />
                        <button class="btn btn-success" v-on:click="ApproveRecord($event, approval.SectionDetail, 1)" v-bind:disabled="!isNotEmptyObject(approval.SectionApprover)">
                            <i class="fa fa-check"></i> 通过adopt
                        </button>
                        <button class="btn btn-danger" v-on:click="ApproveRecord($event, approval.SectionDetail, 2)" v-bind:disabled="!isNotEmptyObject(approval.SectionApprover)">
                            <i class="fa fa-ban"></i> 拒绝refuse
                        </button>

                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

@section scripts{
    <script type="text/javascript" src="~/Scripts/pageJs/Home/Approval.js?v=@DateTime.Now.ToFileTimeUtc()"></script>
}

